package com.itheima.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

public class Demo05 {

    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>(List.of("坤坤", "签签", "滔滔", "鹿鹿", "小绵羊"));
        //获取流//中间方法  终结
        Stream<String> limit = list.stream().limit(3);
        limit.forEach(s-> System.out.println(s));
        System.out.println(limit);
        //limit.skip(1).forEach(s-> System.out.println(s));
        list.stream().skip(2).forEach(s -> System.out.println(s));

        System.out.println("=============");
        //合并两个流
        ArrayList<String> list1 = new ArrayList<>(List.of("谢飞机", "谢广坤", "谢永强", "王小蒙", "王小蒙"));
        Stream<String> stream = list1.stream();
        Stream<String> stream1 = list.stream();
        Stream<String> heliu = Stream.concat(stream, stream1);
        heliu.forEach(s-> System.out.println(s));

        System.out.println("=============");
        //去重
        list1.stream().distinct().forEach(s -> System.out.println(s));


    }
}
